package player.ui;

import java.util.Observable;
import java.util.Observer;

import javax.swing.JTextField;

import player.MusicPlayer;
/**
 * Observer class to observe the tracks that has been playing right now.
 * @author Pawin Suthipornopas 5510546123
 */
public class NowPlayingObserver extends JTextField implements Observer {

	private MusicPlayer player;
	
	/**
	 * Create this observer and assign the music player to it.
	 * @param player is the music player to be assigned.
	 */
	public NowPlayingObserver(MusicPlayer player){
		this.player = player;
		this.setEditable(false);
		this.setText(" Standing By ");
		player.addObserver(this);
	}
	
	@Override
	public void update(Observable o, Object file) {
		if( file == null ){
			this.setText(player.getTrack());
		}
	}

}
